﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using System.Windows.Forms;

namespace QuanLyBanHang
{
    public partial class MasterDetailHD_CTHD : DevExpress.XtraReports.UI.XtraReport
    {
        public MasterDetailHD_CTHD()
        {
            InitializeComponent();
        }
        const string sShowDetail = "Show Detail";
        const string sHideDetail = "Hide Detail";
        ArrayList expandedValues = new ArrayList();

        bool ShouldShowDetail(string maHD)
        {
            return expandedValues.Contains(maHD);
        }
        private void lblShowHide_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            XRLabel lbl = (XRLabel)sender;
            if (ShouldShowDetail(lbl.Tag.ToString()))
            {
                lbl.Text = sHideDetail;
            }
            else
            {
                lbl.Text = sShowDetail;
            }

        }
        private void DetailReport_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            e.Cancel = !ShouldShowDetail(GetCurrentColumnValue("MaHD").ToString());
        }

        private void lblShowHide_PreviewClick(object sender, PreviewMouseEventArgs e)
        {
            string index = e.Brick.Value.ToString();
            bool showDetail = ShouldShowDetail(index);
            if (showDetail)
            {
                expandedValues.Remove(index);
            }
            else
            {
                expandedValues.Add(index);
            }

            // Re-create a document to apply the changes.
            CreateDocument();
        }

        private void lblShowHide_PreviewMouseMove(object sender, PreviewMouseEventArgs e)
        {
            Cursor.Current = Cursors.Hand;
        }

        

    }
}
